<?php

namespace Modules\Buy\Entities;

use Illuminate\Database\Eloquent\Model;

class Arr extends Model
{
    protected $fillable = ['name','pid'];

    public function arrTree(){
        //获取所有分类数据
        $data = Arr::get()->toArray();
        $result = \houdunwang\arr\Arr::tree($data, 'name', 'id', 'pid');
        return $result;
    }

//    属性表与属性表是多对一
    public function attr()
    {
        return $this->belongsTo(Arr::class,'pid','id');
    }    


}
